﻿using B.S.DataBase.MyProject.Domain.Vendors;
using B.S.DataBase.MyProject.ErrorCode;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using T.E.ERP.Read.API.Applicantions.Command.VendorsCommand;
using T.E.ERP.Write.API.Dtos;

namespace T.E.ERP.Read.API.Controllers
{
    /// <summary>
    /// 原料供应商控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class MateSuppliController : ControllerBase
    {
        private readonly IMediator mediator;

        public MateSuppliController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 原料供应商分页显示
        /// </summary>
        /// <param name="get"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<ApiPaging<MateriDtos>>> GetpaginationMaate([FromQuery] GetMateriCommand get)
        {
            return await mediator.Send(get);
        }

        /// <summary>
        /// 原料供品查询
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<List<Supplieditems>>> GetSupplieditems()
        {
            return await mediator.Send(new SuppliCommand());
        }

        /// <summary>
        /// 原料供品表查询
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<List<Supplierprovendor>>> Getprovendor()
        {
            return await mediator.Send(new ProvendorCommand());
        }


        /// <summary>
        /// 选择供应商方法
        /// </summary>
        /// <param name="get"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<List<MaterialSupplier>>> GetMateria([FromQuery] GetMaterCommd get)
        {
            return await mediator.Send(get);
        }

    }
}
